package com.wkbb.common.utils;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.Set;

/**
 * @author luowenyan
 * @version V1.0
 * @className SetUtil
 * @description set工具类
 * @date 2019/9/2 14:26
 */
public class SetUtil {

    /**
     * 获取子set
     * @param objSet
     * @param size
     * @return
     */
    public static Set<Object> subSet(Set<String> objSet, int size) {
        if (CollectionUtils.isEmpty(objSet)) {
            return Collections.emptySet();
        }
        return ImmutableSet.copyOf(Iterables.limit(objSet, size));
    }
}
